//
//  MyOrderTabBarItem.m
//  JHStore
//
//  Created by kiefer on 15-3-27.
//  Copyright (c) 2015年 kiefer. All rights reserved.
//
#define Release(obj) {if (obj) { [(obj) release]; obj = nil; } }
#import "MyOrderTabBarItem.h"

@implementation MyOrderTabBarItem


- (id)initWithFrame:(CGRect)frame 
{
    self = [super initWithFrame:frame];
    if (self) {
               // Initialization code
    
        _selectedLine = [[UIView alloc] init];
        _selectedLine.backgroundColor = [UIColor orangeColor];//color_0xFF3E55;
      
        [self addSubview:_selectedLine];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat boundsW = self.bounds.size.width;
    CGFloat boundsH = self.bounds.size.height;
    CGFloat lineW = boundsW*(100*1.0f/160);
    CGFloat lineH = 2;
    
    if (![self isSelected]) {
        _selectedLine.frame = CGRectMake(boundsW/2 - lineW/2, boundsH - lineH, lineW, lineH);
        _selectedLine.alpha = 1.0f;
        
        [UIView animateWithDuration:0.15f animations:^{
            _selectedLine.alpha = 0.0f;
        }];
    } else {
        _selectedLine.frame = CGRectMake(boundsW/2 - lineW/2, boundsH - lineH, lineW, lineH);
        _selectedLine.alpha = 0.0f;
        
        [UIView animateWithDuration:0.15f animations:^{
            _selectedLine.alpha = 1.0f;
        }];
    }
}

@end
